package crudfx.container;
import crudfx.interop.*;
import crudfx.data.*;
import java.awt.*;
import javax.swing.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class JamTop extends UIComponent {
    var panel:PanelTool;
    public var real:Boolean=false;
    public var realX:Integer=0;
    public var realY:Integer=0;
    public var jam:UIComponent on replace o=n{
        if(o!=null)panel.remove(o.getJComponent());
        if(n!=null){
            panel.add(n.getJComponent(), java.awt.BorderLayout.NORTH);
            }
        panel.validate();
        };
    public var content:UIComponent on replace o=n{
        if(o!=null)panel.remove(o.getJComponent());
        if(n!=null){
            panel.add(n.getJComponent(), java.awt.BorderLayout.CENTER);
            }
        panel.validate();
        };
    function setup():Void{
        panel=new PanelTool(false);
        if(real){
            panel.real=true;
            panel.realX=realX;
            panel.realY=realY;
            }
        var layout:BorderLayout=new BorderLayout();
        panel.setLayout(layout);
        panel.setOpaque(false);
        //panel.setBackground(new java.awt.Color(255,1,1));
        if(this.jam != null){
            panel.add(jam.getJComponent(), java.awt.BorderLayout.NORTH);
            }
        if(this.content != null){
            panel.add(content.getJComponent(), java.awt.BorderLayout.CENTER);
            }
        }
    init{
        setup();
        }
    override public function getJComponent():JComponent{
        return panel;
        }
    override public function highlight(s:String):Boolean{
        if(jam.highlight(s))return true;
        if(content.highlight(s))return true;
        return false;
        }
    override public function gather():DataTree{
        var me:DataTree=DataTree{ name:"JamTop" };
        insert jam.gather() into me.node("jam").children;
        insert content.gather() into me.node("content").children;
        return me;
        }
    }
